package sample.qiplat.plugin.visual;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.rapid.android.ui.widget.editor.CodeVisualizeView;
import com.rapid.android.ui.widget.editor.QiCodeEditor;
import com.rapid.android.ui.widget.editor.VisualizeState;

public class TxtVisualizeView extends CodeVisualizeView<VisualizeState> {
    public final static String CHANNEL_TXT = "v-txt";

    private TextView textView;

    public TxtVisualizeView(Context context) {
        super(context);
        getEditor().setText("我是文本");
    }

    @Override
    public View createVisualizeView(Context context) {
        if (textView == null) {
            textView = new TextView(context);
        }
        return textView;
    }

    @Override
    public void gotoEditMode() {
        QiCodeEditor editor = getEditor();
        editor.setText("编辑模式");
    }

    @Override
    public void gotoVisualizeMode() {
        textView.setText("可视化模式");
    }

    @Override
    public VisualizeState getState() {
        return getBaseState();
    }

    @Override
    public String getChannel() {
        return CHANNEL_TXT;
    }
}
